package com.kongwg.java;

import org.junit.Test;

import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author kongwg
 * @create 2020-12-24 14:16
 */
public class ClassLoaderTest {

    @Test
    public void PropertiesTest() throws Exception {
        Properties pros = new Properties();

        //one
        FileInputStream fis = new FileInputStream("jdbc.properties");

        //two
        ClassLoader classLoader = ClassLoaderTest.class.getClassLoader();
        InputStream is = classLoader.getResourceAsStream("jdbc1.properties");
        pros.load(is);
//        pros.load(fis);
        String user = pros.getProperty("user");
        String password = pros.getProperty("password");

        System.out.println("user=" + user + ",password=" + password);
    }
}
